package com.zx.template.pojo.dto;


import cn.hutool.core.date.DatePattern;
import com.zx.template.base.ValidationGroup;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;


/**
 * 入参例子
 */
@Getter
@Setter
@ToString
@AllArgsConstructor
@NoArgsConstructor
public class ExampleDto {
    
    @ApiModelProperty("作品名称")
    @NotBlank(message = "作品名称 不能为空",groups = {ValidationGroup.Add.class})
    @Length(max = 15,groups = {ValidationGroup.Add.class})
    private String worksName;

    @ApiModelProperty("会员天数")
    @NotNull(message = "会员天数 不能为空",groups = {ValidationGroup.Add.class})
    @Range(min = 1,max = 365,message = "会员天数 不能小于1",groups = {ValidationGroup.Add.class})
    private Integer days;


    // 复合对象校验入参。List<基本类型> 可以在接口处直接进行校验
    @NotEmpty(message = "订单列表不能为空",groups = {ValidationGroup.Add.class})
    @Valid
    List<UserResumeDto> dtoList;
    
    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
    private Date date;
    
}
